package com.wb.test;

/**
 * @author wb
 * @date 2025/1/17 13:54
 */
import com.wb.test.ConnectElasticsearch;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.common.xcontent.XContentType;

public class GetDoc {

    public static void main(String[] args) {
        ConnectElasticsearch.connect(client -> {
//            //1.创建请求对象
//            GetRequest request = new GetRequest().index("user").id("1001");
//            //2.客户端发送请求，获取响应对象
//            GetResponse response = client.get(request, RequestOptions.DEFAULT);
//            //3.打印结果信息
//            System.out.println("_index:" + response.getIndex());
//            System.out.println("_type:" + response.getType());
//            System.out.println("_id:" + response.getId());
//            System.out.println("source:" + response.getSourceAsString());


//            //1.创建请求对象
//            GetRequest request = new GetRequest().index("user").id("1001");
//            //2.客户端发送请求，获取响应对象
//            GetResponse response = client.get(request, RequestOptions.DEFAULT);
//            //3.打印结果信息
//            System.out.println("_index:" + response.getIndex());
//            System.out.println("_type:" + response.getType());
//            System.out.println("_id:" + response.getId());
//            System.out.println("source:" + response.getSourceAsString());


            //创建请求对象
            DeleteRequest request = new DeleteRequest().index("user").id("1001");
            //客户端发送请求，获取响应对象
            DeleteResponse response = client.delete(request, RequestOptions.DEFAULT);
            //打印信息
            System.out.println(response.toString());



        });
    }
}


